package zone.haiwen.demo.domain.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;
import zone.haiwen.demo.dto.Passenger;

/**
 * Description 
 * @author zhangHaiWen
 * @date 2021/7/8 20:09
 * @return 
 **/
@SuppressWarnings("ALL")
@Mapper
public interface PassengerMapper extends BaseMapper<Passenger> {
    /**
     * Description 
     * @author zhangHaiWen
     * @date 2021/7/8 20:09
     * @return void
     **/
    @Select("create table `passenger` (\n" +
            "    `id` bigint(12) not null comment '乘客id',\n" +
            "\t`name` VARCHAR(20) default null comment '乘客姓名',\n" +
            "    `gender` VARCHAR(10) default null comment '乘客性别',\n" +
            "    `age` int(12) default null comment '年龄',\n" +
            "\t`gmt_create` varchar(20) not null comment'主动创建时间',\n" +
            "\t`gmt_modified` varchar(20) not null comment'被动更新时间',\n" +
            "\tPRIMARY KEY(`id`))ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='乘客个人信息表';")
    void createTable();
    
    /**
     * Description 
     * @param  [id , name, gender, age, gmtCreate, gmtModified]
     * @author zhangHaiWen
     * @date 2021/7/8 20:09
     * @return void
     **/
    @Select("insert into passenger (id, name, gender, age, gmt_create, gmt_modified) values(#{id}, #{name}, #{gender}, #{age}, #{gmtCreate}, #{gmtModified})")
    void insert(Long id, String name, String gender, String age, String gmtCreate, String gmtModified);
    
    /**
     * Description 
     * @param [page, name]
     * @author zhangHaiWen
     * @date 2021/7/8 20:09
     * @return com.baomidou.mybatisplus.core.metadata.IPage<zone.haiwen.demo.dto.Passenger>
     **/
    @Select("select * From passenger where name = #{name}")
    IPage<Passenger> getPassengerByName(Page page, @Param("name") String name);
}
